<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>hash</title>
</head>
<body>
  <a href='#/a'>访问a</a>
  <a href='#/b'>访问b</a>
  <div id="root"></div>

  <script>
    let root = document.getElementById('root');
    window.addEventListener('hashchange',()=>{
      console.log(window.location);
      root.innerHTML = window.location.hash.slice(2);
    })
  </script>
</body>
</html>